package com.polylink.${bean.name}.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

import com.mapper.SqlMapper;
import com.polylink.base.Page;
import com.polylink.${bean.name}.bean.${bean.upName};
import com.polylink.${bean.name}.dao.sqlProvider.${bean.upName}SqlProvider;

/**
 *@author xiliang.xiao
 *@date 2015年3月23日 上午9:03:57
 *
 **/
public interface I${bean.upName}Dao extends SqlMapper{

	@Insert("Insert into ${bean.table} (<#list bean.attrs as attr><#if attr.name!="id">${attr.dbName}<#if attr_has_next>,</#if></#if></#list>) "
			+ "value(<#list bean.attrs as attr><#if attr.name!="id">${r"#{"}${attr.name}${r"}"}<#if attr_has_next>,</#if></#if></#list>)")
	public int add(${bean.upName} ${bean.name});

	@SelectProvider(type=${bean.upName}SqlProvider.class,method="list")
	public abstract List<${bean.upName}> list(Page p) ;

	@SelectProvider(type=${bean.upName}SqlProvider.class,method="count")
	public int count(Page p);

	@Update("update ${bean.table} set <#list bean.attrs as attr><#if attr.name!="id">${attr.dbName}=${r"#{"}${attr.name}${r"}"}<#if attr_has_next>,</#if></#if></#list> where id=${r"#{id}"}")
	public int update(${bean.upName} ${bean.name});

	@Delete("delete from ${bean.table} where id in (${r"${id}"})")
	public int delete(@Param("id")String id);

}
